﻿using System;

namespace MiniBlog
{
    public class PostDTO
    {
        public int PostId { get; set; }
        private DateTime date;
        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }

        private string body;
        public string Body
        {
            get { return body; }
            set { body = value; }
        }

        public string Author { get; set; }
        public string Title { get; set; }
        public int CommentsCount { get; set; }

        public static PostDTO CreateFromPost(Post post)
        {
            PostDTO dto = new PostDTO();
            dto.PostId = post.PostId;
            dto.Author = post.Autor;
            dto.Title = post.Title;
            dto.Body = post.Body;
            dto.Date = post.Date;
            dto.CommentsCount = post.Comments.Count;

            return dto;
        }

        public Post ToPost()
        {
            Post post = new Post();
            post.Autor = this.Author;
            post.Title = this.Title;
            post.Body = this.Body;
            post.Date = this.Date;

            return post;
        }



    }
}